package com.fgr.mapper;

import com.fgr.beans.Adapter;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AdapterMapper {

    public List<Adapter> selectAllAdapterAndUser(Integer publish);

    @Select("select * from an_adapter where ad_uid=#{adUid} and ad_publish=0")
    public Adapter selectAdapterByUserId(Integer adUid);

    @Select("select * from an_adapter where ad_id=#{adId}")
    public Adapter selectAdapterByAdId(Integer adId);

    public Adapter selectAdapterAndUserByAdIdAuditing(Integer adId);

    @Insert("insert into an_adapter(ad_uid,ad_anid,ad_time) values (#{adUid},#{adAnid},#{adTime})")
    public Integer insertAdapterAuditing(Adapter adapter);

    @Insert("insert into an_adapter(ad_uid,ad_anid,ad_time,ad_revisit,ad_publish) values(#{adUid},#{adAnid},#{adTime},#{adRevisit},#{adPublish})")
    public Integer addAdapterBg(Adapter adapter);

    @Update("update an_adapter set ad_uid=#{adUid},ad_anid=#{adAnid},ad_time=#{adTime},ad_revisit=#{adRevisit} where ad_id=#{adId}")
    public Integer updateAdapter(Adapter adapter);

    @Delete("delete from an_adapter where ad_id=#{ad_id}")
    public Integer deleteAdapter(Integer ad_id);

    @Update("update an_adapter set ad_publish=1 where ad_id=#{adId}")
    public Integer updateAdapterPublishByAdId(Integer adId);

    }
